package com.by.controller;

import com.by.common.controller.BaseController;
import com.by.common.entity.ResultBean;
import com.by.entity.Product;
import com.by.service.ProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.xml.transform.Result;
import java.util.List;

/*
 * 产品
 * */
@Api(tags = "产品管理")
@RestController
@RequestMapping("/v1")
public class ProductController extends BaseController {
    @Autowired
    private ProductService productService;


    @ApiOperation("产品分类树")
    @GetMapping("/product/query")
    public ResultBean queryProduct() {
        List list =productService.queryProductSort(0);

        return success("查询成功",list);
    }


    @ApiOperation("产品添加")
    @PostMapping("/product")
    public ResultBean product(@RequestBody Product product) {
        int rs = productService.save(product);
        return saveResult(rs);
    }


}
